package com.csf.util;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

public class CookieUitl {

    public static String getVals(HttpServletRequest request,String name){

//        判断参数是否为空
        if (request == null && name == null){
            throw  new IllegalArgumentException("参数不能为空！");
        }

        Cookie[] cookies = request.getCookies();
        if (cookies != null) {
            for (Cookie cookie : cookies) {
               if (cookie.getName().equals(name)){
                   return cookie.getValue();
               }
            }
        }
        return  null;
    }

}
